<template>
  <a-row type="flex" align="top">
    <a-col :span="2">
      <img v-if="userInfo.avatar" :src="userInfo.avatarSrc" style="width: 80px;" />
      <img v-else src="~@/assets/head.png" style="width: 80px;" />
    </a-col>
    <a-col :span="20">
      <p><span class="s1">{{ userInfo.realName }}</span><span class="s2">
          / 风险等级：</span><span class="s2">{{ userInfo.riskCategory }}</span></p>
      <p><span>人员类型：</span><span>{{ setTittle(userInfo.personType) }}</span><span class="s3">
          证件号码：</span><span>{{ userInfo.identityCard }}</span><span class="s3">
          个案编号：</span><span>{{ userInfo.caseNo }}</span><span class="s3">
          负责专干/社工：</span><span>{{ userInfo.belongManagerName }}</span></p>
    </a-col>
  </a-row>
</template>
<script>
import * as flowServiceApi from '@/api/sjsk/flowService'
export default {
  props: ['id', 'isSocial'],
  data() {
    return {
      userInfo: {},
    }
  },
  created() {
    console.log("11111")
    console.log(this.isSocial)
    if (this.isSocial) { //社会面人员
      this.getSocialPersonInfo()
    } else { //社戒社康人员
      this.getSjskPersonInfo()
    }

  },
  methods: {
    getSjskPersonInfo() {
      flowServiceApi
        .getSjskPersonInfo(this.id)
        .then((res) => {
          if (res.success) {
            this.userInfo = res.result ? res.result : {}
            this.userInfo.personType = this.userInfo.sjskType
            if (this.userInfo.highRiskSituation == 1) this.userInfo.riskCategory = "高"
            if (this.userInfo.highRiskSituation == 2) this.userInfo.riskCategory = "中"
            if (this.userInfo.highRiskSituation == 3) this.userInfo.riskCategory = "低"
          } else {
            this.$message.warn('请求失败！')
          }
        })
        .catch((e) => {
          this.$message.warn('请求失败！')
        })
    },
    getSocialPersonInfo() {
      flowServiceApi
        .getSocialPersonInfo(this.id)
        .then((res) => {
          if (res.success) {
            this.userInfo = res.result ? res.result : {}
            if (this.userInfo.riskCategory == 1) this.userInfo.riskCategory = "高"
            if (this.userInfo.riskCategory == 2) this.userInfo.riskCategory = "中"
            if (this.userInfo.riskCategory == 3) this.userInfo.riskCategory = "低"
          } else {
            this.$message.warn('请求失败！')
          }
        })
        .catch((e) => {
          this.$message.warn('请求失败！')
        })
    },
    setTittle(text) {
      return this.$filterDictTextByCache('personType', text)  //现在字典中对应的文字，是全局函数
    },
  },
}
</script>
<style lang="less" scoped>
.s1 {
  font-size: 20px;
  font-weight: bold;
}

.s2 {
  // color: #04B615;
}

.s3 {
  margin-left: 30px;
}
</style>
